import { STOCK_ATTR_OPTION, SIGN_CONTRACT_OPTION } from '@/pages/sourcing/constants'
import { list2Obj } from '@/utils/bizUtils'
// 单据状态
const STATE_OPTION = [
  { label: '询价中', value: 100 },
  { label: '订货待审批', value: 200 },
  { label: '待生成订单', value: 300 },
  { label: '询价完成', value: 400 },
  { label: '询价取消', value: 500 },
]
// 操作列不同状态不同列宽
export const ACTION_WIDTH_OBJ = {
  '100': 110,
  '200': 100,
  '300': 180,
  '400': 100,
  '500': 100,
}
export const FORM_ITEMS = [
  {
    prop: 'reqPurchaseOrderTime',
    label: '要求下单时间',
    type: 'dateRangePicker'
  },
  // creationDateStart creationDateEnd
  {
    prop: 'creationDate',
    label: '制单时间',
    type: 'dateRangePicker'
  },
  {
    prop: 'billNo',
    label: '询价单号',
    type: 'input'
  },
  {
    prop: 'shortSupplyCompanyName',
    label: '缺货公司',
    type: 'input'
  },
  {
    prop: 'creationDept',
    label: '采购询价部门',
    type: 'input'
  },
  {
    prop: 'creation',
    label: '上游制单人',
    type: 'input'
  },
  {
    prop: 'skuCode',
    label: '商品代码',
    type: 'input'
  },
  {
    prop: 'skuName',
    label: '商品名称',
    type: 'input'
  },
  {
    prop: 'isExceedNum',
    label: '超1.2倍要货',
    type: 'select',
    options: SIGN_CONTRACT_OPTION
  },
  {
    prop: 'isExceedThreeOut',
    label: '超三月销量',
    type: 'select',
    options: SIGN_CONTRACT_OPTION
  },
  {
    prop: 'stockAttr',
    label: '存量属性',
    type: 'select',
    options: STOCK_ATTR_OPTION
  },
]

export const TABLE_COLUMNS = [
  {
    prop: 'creationDate',
    label: '制单时间',
    width: 140
  },
  {
    prop: 'billStatus',
    label: '询价状态',
    formatter: (row, column, cellValue) => {
      return list2Obj(STATE_OPTION)[cellValue]
    }
  },
  {
    prop: 'reqPurchaseOrderTime',
    label: '要求下单时间',
    width: 140
  },
  {
    prop: 'billNo',
    label: '询价单号',
    width: 140
  },
  {
    prop: 'shortSupplyCompanyName',
    label: '缺货公司',
    width: 100
  },
  {
    prop: 'creationDept',
    label: '采购询价部门',
    width: 100
  },
  {
    prop: 'creation',
    label: '上游制单人',
  },
  {
    prop: 'deliveryAddress',
    label: '送货地址',
  },
  {
    prop: 'skuCode',
    label: '商品代码',
  },
  {
    prop: 'skuName',
    label: '商品名称',
  },
  {
    prop: 'fourCategoryCode',
    label: '分类代码',
  },
  {
    prop: 'oneCategoryName',
    label: '分类名称',
  },
  {
    prop: 'productSpec',
    label: '规格',
  },
  {
    prop: 'unit',
    label: '计量单位',
  },
  {
    prop: 'stockName',
    label: '库房',
  },
  {
    prop: 'pieceQty',
    label: '件装数量',
  },
  {
    prop: 'maxPackageQty',
    label: '最大包装数',
  },
  {
    prop: 'minPackageQty',
    label: '最小包装数',
  },
  {
    prop: 'lowerQty',
    label: '下限',
  },
  {
    prop: 'upperQty',
    label: '上限',
  },
  {
    prop: 'purchaseTransitQty',
    label: '采购在途',
  },
  {
    prop: 'transferTransitQty',
    label: '转货在途',
  },
  {
    prop: 'shortageGoods',
    label: '调货短缺',
  },
  {
    prop: 'shortageGoodsQty',
    label: '短缺数量',
  },
  {
    prop: 'physicalStock',
    label: '实物库存',
  },
  {
    prop: 'physicalSellQty',
    label: '实物可售',
  },
  {
    prop: 'stockAttr',
    label: '存量属性',
    formatter: (row, column, cellValue) => {
      return list2Obj(STOCK_ATTR_OPTION)[cellValue]
    }
  },
  {
    prop: 'purchaseOrderCode',
    label: '采购订单号',
  },
  {
    prop: 'priceExpTypes',
    label: '采购异常类型',
  },
  {
    prop: 'amount',
    label: '要货数量',
  },
  {
    prop: 'threeOut',
    label: '三个月销量',
  },
  {
    prop: 'thisPeriodOut',
    label: '同期出库',
  },
  {
    prop: 'allYearOut',
    label: '全年出库',
  },
  {
    prop: 'isExceedThreeOut',
    label: '是否超3个月销量',
  },
  {
    prop: 'exceedThreeOutReason',
    label: '超三月销量原因',
  },
  {
    prop: 'isExceedNum',
    label: '是否超1.2倍要货',
  },
  {
    prop: 'exceedNumReason',
    label: '超过1.2倍要货原因',
  },
]

// 下推采购订单商品表格
export const ORDER_INFO_TABLE_COLUMNS = [
  {
    key: 'factoryCode',
    title: '厂家商品代码',
    width: 100
  },
  {
    key: 'factoryName',
    title: '厂家商品名称',
    width: 100
  },
  {
    key: 'skuCode',
    title: '商品代码',
  },
  {
    key: 'skuName',
    title: '商品名称',
  },
  {
    key: 'skuTypeStr',
    title: '商品类型',
  },
  {
    key: 'categoryName',
    title: '品类名称',
  },
  {
    key: 'categoryCode',
    title: '品类编码',
  },
  {
    key: 'skuSpecifications',
    title: '规格型号',
  },
  {
    key: 'skuUnit',
    title: '计量单位',
    width: 90
  },
  {
    key: 'assistSkuUnit',
    title: '辅计量单位',
    width: 90
  },
  {
    key: 'unitPrice',
    title: '进价',
    width: 90
  },
  {
    key: 'assistUnitPrice',
    title: '辅进价',
    width: 90
  },
  {
    key: 'skuNum',
    title: '数量',
    width: 60
  },
  {
    key: 'assistSkuNum',
    title: '辅数量',
    width: 70
  },
  {
    key: 'skuPrice',
    title: '金额',
    width: 100
  },
]
